package com.ymatou.iapi.trading.sellerquery2.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymatou.query.seller.trading.api.parameter.Seller.GetSellerOrdersByIdsResponse;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;

/**
 * 根据多个订单号查询Call FreeMaker Template自动生成代码
 */
public class GetSellerOrdersByIdsCall extends YmatouBaseCall {
	private static String opurl = "api/Seller/GetSellerOrdersByIds";

	public GetSellerOrdersByIdsCall() {
		super(EnvSetup.getSystemUrl("sellerquery2_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	// get data
	public JSONObject getData() {
		JSONObject data = null;
		try {
			data = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return data;
	}

	public String getCode() {
		String code = null;
		try {
			code = new JSONObject(getReturnData()).getString("code");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return code;
	}

	public GetSellerOrdersByIdsResponse getSellerOrdersByIdsResponse() {
		String s = DataUtil.Json.parseJsonObj(getData().toString()).toString();
		return (GetSellerOrdersByIdsResponse) FormatUtil.GSONToObject(s,
				GetSellerOrdersByIdsResponse.class);
	}

}